//
//  AdvertisingTableViewCell.m
//  WanCaiC8
//
//  Created by 罗先森 on 2018/9/18.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "AdvertisingTableViewCell.h"

@implementation AdvertisingTableViewCell{
    UIButton *btn;
    UIView *line;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
        
}

-(void)setupUI{
    
    
    line=[[UIView alloc]init];
    line.backgroundColor=DEFAULTBGCOLOR;
    line.hidden=YES;
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.contentView);
        make.height.mas_equalTo(@.7);
    }];
    
    btn = [UIButton new];
    btn.titleLabel.font = [UIFont systemFontOfSize: 13.0];
    

    btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    btn.titleEdgeInsets = UIEdgeInsetsMake(0, 17, 0, 0);
    
    
    
    [btn setTitleColor:DEFAULTTEXTGDARKRAYCOLOR forState:UIControlStateNormal];
    
    btn.userInteractionEnabled = NO;

    [self.contentView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.equalTo(self.contentView);
        make.height.mas_equalTo(@38);
        make.centerY.equalTo(self.contentView);

    }];
    
    
    UIView *line1=[[UIView alloc]init];
    line1.backgroundColor=DEFAULTBGCOLOR;
    
    [self.contentView addSubview:line1];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(17);
        make.right.equalTo(self.contentView).offset(-17);

        make.height.mas_equalTo(@.7);
    }];
}


-(void)setModel:(AdvertisingModel *)model{
    
    _model=model;
    
    if ([model.Title containsString:@"【"]) {
        [btn setAttributedTitle:[NSAttributedString tg_imageTextWithTitle:model.Title] forState:UIControlStateNormal];
    } else {
        [btn setTitle:model.Title forState:UIControlStateNormal];
    }
}





- (void)showLine:(BOOL)isHidden{
    line.hidden=isHidden;
}

@end
